﻿<html xmlns:th="http://www.thymeleaf.org">
<head>
	<!--资源获取-->
	<base th:href="|${#request.getContextPath()}/|">
	<meta charset="utf-8">
	<meta name="renderer" content="webkit|ie-comp|ie-stand">
	<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
	<meta name="viewport"
		  content="width=device-width,initial-scale=1,minimum-scale=1.0,maximum-scale=1.0,user-scalable=no"/>
	<meta http-equiv="Cache-Control" content="no-siteapp"/>
	<!--[if lt IE 9]>
	<script type="text/javascript" src="static/lib/html5shiv.js"></script>
	<script type="text/javascript" src="static/lib/respond.min.js"></script>
	<![endif]-->
	<link rel="stylesheet" type="text/css" href="static/h-ui/css/H-ui.min.css"/>
	<link rel="stylesheet" type="text/css" href="static/h-ui.admin/css/H-ui.admin.css"/>
	<link rel="stylesheet" type="text/css" href="static/lib/Hui-iconfont/1.0.8/iconfont.css"/>
	<link rel="stylesheet" type="text/css" href="static/h-ui.admin/skin/default/skin.css" id="skin"/>
	<link rel="stylesheet" type="text/css" href="static/h-ui.admin/css/style.css"/>
	<!--[if IE 6]>
	<script type="text/javascript" src="static/lib/DD_belatedPNG_0.0.8a-min.js"></script>
	<script>DD_belatedPNG.fix('*');</script>
	<![endif]-->
	<!--layui-->
	<link rel="stylesheet" type="text/css" href="static/layui/css/layui.css"/>



    <title>世界排名</title>
</head>
<body>
<nav class="breadcrumb"><i class="Hui-iconfont">&#xe67f;</i> 首页 <span class="c-gray en">&gt;</span> 模拟投资 <span
        class="c-gray en">&gt;</span> 世界排名 <a class="btn btn-success radius r" style="line-height:1.6em;margin-top:3px"
                                              href="javascript:location.replace(location.href);" title="刷新"><i
        class="Hui-iconfont">&#xe68f;</i></a>
    <!--收藏-->
    <a id="djsc" class="btn btn-success radius r " style="line-height:1.6em;margin-top:3px" href="javascript:;"
       title="收藏">
        <i id="sc" class=" Hui-iconfont">&#xe69d;</i>
        <i id="qxsc" class=" Hui-iconfont">&#xe69e;</i></a>
    <!--收藏-->
</nav>
<table class="table">
    <tr>
        <td width="200" class="va-t">
			<div class="layui-btn-container">
				<button type="button" class="layui-btn layui-btn-sm" id="sub" lay-demo="getChecked">选择比赛</button>
			</div>
			<div id="test12" class="demo-tree-more"></div>
        </td>
        <td class="va-t">
			<table id="WorldRankingTable" lay-filter="test"></table>
			<script type="text/html" id="barDemo">
				<a class="layui-btn layui-btn-xs" lay-event="edit">详细</a>
			</script>
        </td>
    </tr>
</table>
<!--_footer 作为公共模版分离出去-->
<script type="text/javascript" src="static/lib/jquery/1.9.1/jquery.min.js"></script>
<script type="text/javascript" src="static/h-ui/js/H-ui.min.js"></script>
<script type="text/javascript" src="static/h-ui.admin/js/H-ui.admin.js"></script> <!--/_footer 作为公共模版分离出去-->

<script type="text/javascript" src="static/lib/layer/2.4/layer.js"></script>
<script type="text/javascript" src="static/lib/laypage/1.2/laypage.js"></script>
<!--请在下方写此页面业务相关的脚本-->
<script type="text/javascript" src="static/lib/zTree/v3/js/jquery.ztree.all-3.5.min.js"></script>
<!--layui-->
<link rel="stylesheet" type="text/css" href="static/layui/css/layui.css"/>
<script type="text/javascript" src="static/layui/layui.js"  charset="utf-8"></script>
<script type="text/javascript">
    /*收藏按钮*/
    var ejhref = "WorldList/Investment-WorldList";//收藏路径
    $.ajax({
        url: "CollectionPage?page=" + ejhref,
        async: false,
        type: "GET",
        success: function (datas) {
            if (datas == "sc") {

                $("#qxsc").addClass("layui-hide");
                $("#sc").addClass("layui-show");

            } else {
                $("#sc").addClass("layui-hide");
                $("#qxsc").addClass("layui-show");
            }
        }
    })
    $("#djsc").on("click", function () {
		/*收藏*/
		var ejhrefi = ejhref;
		shoucangpage(ejhrefi,"世界排名")
    })
	function shoucangpage(ejhrefi,ejname) {
		$.ajax({
			url: "CollectionNewPage",
			type: "POST",
			data: {
				"page": ejhrefi,
				"pageName":ejname //收藏名字
			},
			success: function (regas) {
				if (regas != "sc") {

					$("#qxsc").attr("class", "Hui-iconfont layui-hide");
					$("#sc").attr("class", "Hui-iconfont layui-show");

				} else {
					$("#sc").attr("class", "Hui-iconfont layui-hide");
					$("#qxsc").attr("class", "Hui-iconfont layui-show");
				}

			}
		})
	}
	/*tree*/

	layui.use(['tree','table'], function(){
		var tree = layui.tree;
		var table = layui.table;//WorldRankingTable
		//表
		table.render({
			elem: '#WorldRankingTable'
			,url: 'WorldList/WorldPmList' //数据接口
			,id: 'tableworld'
			,page: true //开启分页
			,where:{
				"zqId":[0]
			}
			,cols: [
			[ //表头
				{field: 'username', title: '用户名', sort: true, fixed: 'left'}
				,{field: 'zqname', title: '赛道名'}
				,{field: 'amount', title: '金额',sort: true}
				,{field: 'top', title: '排名'}
				, {fixed: 'right', title: '操作', toolbar: '#barDemo', width: 100}
			]
			],error:function (r,a) {
				console.log(r);
				console.log(a);
				return '请先选择比赛';
			}
		});
		//渲染
		var treeWorld ='';
		$.ajax({
			url:"WorldList/WorldList",
			type:"GET",
			async: false,
			success:function (reg) {
				console.log(reg);
				treeWorld = reg;
			}
		})
		var ins = tree.render({
			elem: '#test12'  //绑定元素
			,id : 'tree1'
			,showCheckbox : true
			,data: treeWorld

		});
		// 监听点击按钮
		table.on('tool(test)', function (obj) {
			var data = obj.data;
			//console.log(obj)
			console.log(obj);
			if (obj.event === 'edit') {
				layer.open({
					type: 2,
					title: '我的投资',
					area: ['90%', '90%'],
					fixed: false, //不固定
					maxmin: true,
					content: 'TouZi/TzmxHtml?zqId='+data.zqId+'&uId='+data.uId
				})
			}
		});
		function getCheckedId(data) {
			var id = "";
			$.each(data, function (index, item) {
				if (id != "") {
					id = id + "," + item.id;
				}
				else {
					id = item.id;
				}
				//item 没有children属性
				if (item.children != null) {
					var i = getCheckedId(item.children);
					if (i != "") {
						id = id + "," + i;
					}
				}
			});
			console.log(id)
			return id;
		}
		$("#sub").click(function(){
			//获取所有选中节点id数组
			var a = new Array();
			console.log($(".layui-form-checked").prev().each(function () {
				if($(this).val()!="null"){
					a.push($(this).val());
				}
			}));
			table.reload("tableworld", {
				where:{
					"zqId" :a
				}
			})
		});
		//获取所有选中的节点id

		/*tree*/
	});


    var code;

    function showCode(str) {
        if (!code) code = $("#code");
        code.empty();
        code.append("<li>" + str + "</li>");
    }
</script>
</body>
</html>